package com.jh.paymentchannel.service;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jnewsdk.util.StringUtils;
@Controller
@EnableAutoConfiguration
public class KuaiJieInfoPage {
	 
	private static final Logger LOG = LoggerFactory.getLogger(KuaiJieInfoPage.class);
	
	
	@RequestMapping(method=RequestMethod.GET,value="/v1.0/paymentchannel/topup/kuaijie")
	public  String returnpay(HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
		
		Map map = new HashMap();
		// 设置编码
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String bankName = request.getParameter("bankName");
		String bankNo = request.getParameter("bankNo");
		String amount = request.getParameter("amount");
		String ordercode = request.getParameter("ordercode");
		String province = request.getParameter("province");
		String city = request.getParameter("city");
		String bankBranchName = request.getParameter("bankBranchName");
		String bankBranchId = request.getParameter("bankBranchId");
		String securityCode = request.getParameter("securityCode");
		String expiredTime = request.getParameter("expiredTime");
		String channelParam = request.getParameter("channelParam");
		LOG.info("接口/v1.0/paymentchannel/topup/kuaijie——@bankName="+bankName+"@bankNo="+bankNo+"@amount="+amount+"@ordercode="+ordercode+"@province="+province+"@city="+city+"@bankBranchName="+bankBranchName+"@bankBranchId="+bankBranchId+"@channelParam="+channelParam);
		if (StringUtils.isEmpty(bankName)) {
			model.addAttribute("RespCode", "9999");
			model.addAttribute("RespMsg", "没有绑定借记卡");
			 return "ailongpay_err";
		} else {
			model.addAttribute("bankName", bankName);
			model.addAttribute("bankNo",bankNo);
			model.addAttribute("amount", amount);
			model.addAttribute("ordercode", ordercode);
			model.addAttribute("province", province);
			model.addAttribute("city", city);
			model.addAttribute("bankBranchName", bankBranchName);
			model.addAttribute("bankBranchId", bankBranchId);
			model.addAttribute("securityCode", securityCode);
			model.addAttribute("expiredTime", expiredTime);
			model.addAttribute("channelParam", channelParam);
			
			return "bankInfo";
		}
		
	}
	
}
